package com.ceba.test.base.configs;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import abc.certificate.CertificationFactory;
import com.ceba.base.config.CommonConfig;
import com.ceba.base.dbdata.MysqlUtils;
import com.ceba.base.enums.FileDefaultStoragePathFlagEnum;
import com.ceba.base.enums.FileStorageFalgeEnum;
import com.ceba.base.enums.LanguageTypeEnum;
import com.ceba.base.helper.LoggerHelper;
import com.ceba.base.stamp.StampFontFactory;
import com.ceba.base.utils.IDSStringUtils;
import com.ceba.cebautils.DateUtil;
import com.ceba.cebautils.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import abc.Value;

public class CebaConfig extends CommonConfig {


	private static Logger logger = LoggerFactory.getLogger(CebaConfig.class);

	public static String ANDMIN_USER_ID="999999999999999999999999999999";
	public static String ANDMIN_USER_EMAIL_ID="1";
	public static String FILE_STORAGE_DEFAULT_ID="55555555555555555555555555555555";//文件存储默认ID

	public static String BATCH_SIGN;

	public static String USE_VERSION;
	public static String SIGN_FILE_MAX;
	public static String SIGN_FILE_MORE;
	public static int ZIP_DOWN_MAX_SIZE;
	public static int SEND_MAIL_MAX_SIZE;
	public static String MAX_SIZE = "";

	/*全部签名报告文档份数*/
	public static String ALL_SIGNCOUNT_REPORT = "";
	/*全部签名附件文档份数*/
	public static String ALL_SIGNCOUNT_ATTACH = "";
	/*今年全部签名报告文档份数*/
	public static String YEAR_SIGNCOUNT_REPORT = "";
	/*今年全部签名附件文档份数*/
	public static String YEAR_SIGNCOUNT_ATTACH = "";

	//是否显示签名目录配置
	public static String SHOW_DIR_MANAGE;
	//lic导入时间
	public static String LICENSE_IMPORT_TIME;

	public static String VISIT_IP = "";

	public static String VISIT_IP_ALL = "all";

	public static String PDF_TRANSFORM_URL;
	public static String PDF_TRANSFORM_SOCKET_PORT;


	//二维码公共属性
	public static String QRCODE;
	public static String QRCODE_HEIGTH;
	public static String QRCODE_MATCH_NAME;
	public static String QRCODE_WIDTH;
	//采用be配置还是使用二维码云服务 QrServiceMethodEnum
	public static String QRCODE_SERVICE_METHOD;
	//二维码公共属性 end

	//二维码访问服务器IP
	public static String QR_SERVER_IP_PORT;
	//二维码访问前缀
	public static String QR_SERVER_PREFIX;
	//二维码PDF上传接口
	public static String QR_PDF_UPLOAD_ITF;
	//二维码PDF查询接口
	public static String QR_PDF_QUERY_ITF;

	//是否立即上传服务器
	public static String QR_PDF_NEED_UPLOAD;

	//用户是否显示配置骑缝章
	public static String QIFENG_FLAG;

	//用户是否显示配置封面和尾页
	public static String REPORTMERGE_FLAG;

	//用户是否可以选择资质章--目前用于佛山计量局
	public static String SELECT_CREDENTIALS_FLAG;

	//指纹KEY启动
	public static String FINGER_KEY_FLAG;

	//手写板启动
	public static String HAND_BAG_FLAG;
	//手写签名
	public static String HAND_WRITE_SIGN;


	public static String NETTY_SERVER_IP;
	public static String NETTY_SERVER_PORT;

	public static String KEY_MULTI_LABLE_FLAG;//key模式是否多签名开关true --打开多签  false--关闭多签

	//登录方式,0-用户名密码登录 ,1-AD域登录
	public static String LOGIN_TYPE;

	//个人邮箱配置0--隐藏  1--显示)
	public static String HIDDEN_EMAIL_FLAG;

	//是否显示Logo 0 不显示  1 显示富士康logo
	public static String PATTER_LOGO_FLAG;

	//获取本地域名的请求地址
	public static String AD_SERVER_NET_URL;

	//关键字中包含这些符号时，匹配关键字过滤掉
	public static String specialKeyWorkPrefixSuffix="()$（）￥%<>《》\\[\\]【】#~+=&";

	//签章自动匹配 0--关闭  1---开启
	public static String AUTOMATIC_SIGNATURE_FLAG;

	//签章属性是否更改开关 false--关闭  true---开启
	public static String ENCROPYT_TO_PDF;

	/**
	 * 限制访问IP是否为一个或多个IP,true为只能限制一个
	 */
	public static boolean limitIp = true;


	//每次最多合并文档个数
	public static String MERGE_MAX_COUNT = "5";

	//手写签名二维码IP
	public static String HAND_WRITE_QR_URL;

	//文件存储管理是否开启标识
	public static FileStorageFalgeEnum FILE_STORAGE_FALG;//文件存储管理是否标识 1.启动  2 未启动

	public static FileDefaultStoragePathFlagEnum FILE_DEFAULT_STORAGE_PATH_FLAG;//文件存储默认插入的地址  默认地址有没有 修改  1.修改  0 未修改

	public static  String BE_KEY_FLAG ;//签名模式
    public static int WordToPfdMaxSize;//转换文档允许的最大数量；默认值20M

	//----------------------------已下字段非数据库中字段---------------------------
	public static int FILE_STORAGE_HINT_VALUE=10240;//文件存储提示值，单位M；默认值10240M=10G
	public static int FILE_STORAGE_CHANGE_VALUE=512;//文件存储切换值，单位M；默认值5120M=5G

	public static String CUSTOM_DATE_FORMAT = DateUtil.YYYY_MM_DD;
	public static String CUSTOM_DATE_FONT = StampFontFactory.FontFimilyEnum.CLASSICAL_SU_TONG.getCode();


	public static String SIGN_CHANNEL_TYPE = "2";   //签名通信方式 1-socket 2-http

	/**
	 * 自动重传二维码上传失败的任务间隔
	 * 默认值：每5分钟重试一次
	 * 如要修改，遵循cron表达式格式
	 */
	public static String QR_FILE_UPLOAD_TIME = "0 0/5 * * * ?";

	//cnca直报系统URL。必填
	public static String CNCA_URL;
	//调用方标识。必填
	public static String CNCA_UID;
	//调用方用户名。必填
	public static String CNCA_USERNAME;
	//调用方密码。必填
	public static String CNCA_PASSWORD;
	//检测机构名称。必填
	public static String CNCA_ORG_NAME;
	//组织机构代码。必填
	public static String CNCA_ORG_CODE;

	//是否显示"数字签名(加密)签/章配置"
	public static boolean SIGNATURE_STAMP_FLAG = true;
	//是否显示"其他签/章配置"
	public static boolean OTHER_STAMP_FLAG = true;
	//是否显示"水印配置"
	public static boolean WATERMARK_STAMP_FLAG = true;

	/**
	 * 一页纸的pdf是否应用骑缝章
	 * true：一页纸的pdf盖上骑缝章；false：一页纸的pdf不盖骑缝章
 	 */
	public static boolean IS_QIFENG_IN_ONE_PAGE_PDF = true;

	public static int MAX_SIGNING_NUMBER_IN_API = 20;

	public static String OFD_SERVICE_URL = "http://localhost:8070";

	//用户签名功能界面上是否展示可复制
	public static boolean SHOW_USER_ALLOW_COPY_VIEW = false;
	//用户签名功能界面上是否展示可添加二维码
	public static boolean SHOW_USER_ALLOW_ADD_QR_VIEW = false;
	//用户签名功能界面上可添加二维码默认不添加
	public static boolean DEFAULT_USER_ALLOW_ADD_QR = false;
	//控制签名时关键字没匹配上是否报错 true-不报错 false-报错
	public static boolean NO_ERROR_NOT_NORMAL_MATCH_KEY = false;

	//控制API签名时关键字没匹配上是否报错 true-不报错 false-报错
	public static boolean NO_ERROR_NOT_NORMAL_MATCH_API_KEY = false;

	//控制API签名时添加二维码默认不添加
	public static boolean ADD_QR_FOR_API_KEY = false;

	public static Map<String, Object> tuvParamMap = new HashMap();


	static{
		try{
			init();
			System.out.println("系统启动成功.");
			logger.debug("系统启动成功---");
		}catch(Exception e){
			logger.debug("系统启动失败---");
			LoggerHelper.error(logger, e, "");
		}
	}

	public static void init() throws Exception{
		MAX_SIZE = get("MAX_SIZE");
		HIDDEN_EMAIL_FLAG = get("HIDDEN_EMAIL_FLAG");
		LOGIN_TYPE = get("LOGIN_TYPE");
		PATTER_LOGO_FLAG = get("PATTER_LOGO_FLAG");
		BATCH_SIGN = get("BATCH_SIGN");
		SIGN_TYPE = get("SIGN_TYPE");
		AUTOMATIC_SIGNATURE_FLAG = get("AUTOMATIC_SIGNATURE_FLAG");
		SIGN_VALIDITY = get("SIGN_VALIDITY");
		SIGN_COMPANY = getDecode(get("SIGN_COMPANY"));
		BACKUP_PATH = get("BACKUP_PATH");
		KEY_MULTI_LABLE_FLAG = get("KEY_MULTI_LABLE_FLAG");
		AD_SERVER_NET_URL = get("AD_SERVER_NET_URL");
		NEED_BACKUP = get("NEED_BACKUP");
		USE_VERSION = get("USE_VERSION");
		SIGN_FILE_MAX = get("SIGN_FILE_MAX");
		SIGN_FILE_MORE = get("SIGN_FILE_MORE");
		ENCROPYT_TO_PDF = get("ENCROPYT_TO_PDF");
		ZIP_DOWN_MAX_SIZE= Integer.parseInt(get("ZIP_DOWN_MAX_SIZE"));
		if(ZIP_DOWN_MAX_SIZE==0){
			ZIP_DOWN_MAX_SIZE=1024*1024*25;
		}
		SEND_MAIL_MAX_SIZE= Integer.parseInt(get("SEND_MAIL_MAX_SIZE"));
		if(SEND_MAIL_MAX_SIZE==0){
			SEND_MAIL_MAX_SIZE=1024*1024*5;
		}
		PDF_CREATE_MODE = get("PDF_CREATE_MODE");
		ALLOW_SIGN_NUM = getDecode(get("ALLOW_SIGN_NUM"));
		SING_COMPANY_ACTIVATE_FLAG = get("SING_COMPANY_ACTIVATE_FLAG");
		SVN_VERSION = get("SVN_VERSION");
		VERSION = get("VERSION");
		PDF_TRANSFORM_URL = get("PDF_TRANSFORM_URL");
		PDF_TRANSFORM_SOCKET_PORT = get("PDF_TRANSFORM_SOCKET_PORT");

		ALLOW_LOGIN_DATE=getDecode(get("ALLOW_LOGIN_DATE"));

		SHOW_DIR_MANAGE = get("SHOW_DIR_MANAGE");

		REMOTE_NEW_SIGN_COUNT = getDecode(get("REMOTE_NEW_SIGN_COUNT"));

		VISIT_IP = getDecode(get("VISIT_IP"));

		QRCODE = get("QRCODE");
		QRCODE_HEIGTH = get("QRCODE_HEIGTH");
		QRCODE_MATCH_NAME = get("QRCODE_MATCH_NAME");
		QRCODE_WIDTH = get("QRCODE_WIDTH");
		QRCODE_SERVICE_METHOD = get("QRCODE_SERVICE_METHOD");
		QR_SERVER_IP_PORT = get("QR_SERVER_IP_PORT");
		QR_SERVER_PREFIX = get("QR_SERVER_PREFIX");
		QR_PDF_NEED_UPLOAD = get("QR_PDF_NEED_UPLOAD");
		QR_PDF_UPLOAD_ITF = get("QR_PDF_UPLOAD_ITF");
		QR_PDF_QUERY_ITF = get("QR_PDF_QUERY_ITF");


		NETTY_SERVER_IP = get("NETTY_SERVER_IP");
		NETTY_SERVER_PORT = get("NETTY_SERVER_PORT");
		BE_KEY_FLAG = get("BE_KEY_FLAG");
		//默认值
		if(StringUtils.isEmpty(QR_SERVER_PREFIX)){
			QR_SERVER_PREFIX=CebaPathUtil.getWebRootName()+"/qRPdfAction?action=";
			set("QR_SERVER_PREFIX",QR_SERVER_PREFIX);
		}
		if(StringUtils.isEmpty(QR_PDF_UPLOAD_ITF)){
			QR_PDF_UPLOAD_ITF="uploadQRPdf";
			set("QR_PDF_UPLOAD_ITF",QR_PDF_UPLOAD_ITF);
		}
		if(StringUtils.isEmpty(QR_PDF_QUERY_ITF)){
			QR_PDF_QUERY_ITF="queryQRPdf";
			set("QR_PDF_QUERY_ITF",QR_PDF_QUERY_ITF);
		}

		SYSTEM_START_TIME = get("SYSTEM_START_TIME");

		QIFENG_FLAG = get("QIFENG_FLAG");

		REPORTMERGE_FLAG=get("REPORTMERGE_FLAG");

		SYSTEM_TYPE = getDecode(get("SYSTEM_TYPE"));

		COLLECT_SQL_FLAG = getDecode(get("COLLECT_SQL_FLAG"));

		ENTERPRISEREGISTER_CONFIG_FLAG = getDecode(get("ENTERPRISEREGISTER_CONFIG_FLAG"));

		FINGER_KEY_FLAG = get("FINGER_KEY_FLAG");
		HAND_BAG_FLAG = get("HAND_BAG_FLAG");
		HAND_WRITE_SIGN = get("HAND_WRITE_SIGN");

		MERGE_MAX_COUNT = get("MERGE_MAX_COUNT");


		SELECT_CREDENTIALS_FLAG = get("SELECT_CREDENTIALS_FLAG");

		SYSTEM_FEE_TYPE = get("SYSTEM_FEE_TYPE");

		SYSTEM_DEFAULTS_LANGUAGE = get("SYSTEM_DEFAULTS_LANGUAGE");
		SYSTEM_PRODUCT_NAME = get("SYSTEM_PRODUCT_NAME");
		WATERMARK_OVERCONTENT_FLAG = get("WATERMARK_OVERCONTENT_FLAG");

		String flag=get("FILE_STORAGE_FALG");
		FILE_STORAGE_FALG=FileStorageFalgeEnum.getFlag(flag);
		flag=get("FILE_DEFAULT_STORAGE_PATH_FLAG");
		FILE_DEFAULT_STORAGE_PATH_FLAG=FileDefaultStoragePathFlagEnum.getFlag(flag);

		SHCA_KEY_FLAG = get("SHCA_KEY_FLAG");

		if(Boolean.TRUE.equals(StringUtil.isEmptyString(SYSTEM_DEFAULTS_LANGUAGE))){
			SYSTEM_DEFAULTS_LANGUAGE = LanguageTypeEnum.zhCN.getCode();
		}


		if(Boolean.TRUE.equals(StringUtil.isEmptyString(SYSTEM_DEFAULTS_LANGUAGE))){
			SYSTEM_DEFAULTS_LANGUAGE = LanguageTypeEnum.zhCN.getCode();
		}

		if(StringUtils.isNumeric(SIGN_TYPE)){
			CertificationFactory.certificationType=Value.getInt(SIGN_TYPE, 0);
		}
		else {
			CertificationFactory.certificationType = 1;
		}
		readSetting();
	}

	private static void readSetting(){
		FileInputStream in = null;
		try {
			String path = CebaConfig.class.getClassLoader().getResource("").toURI().getPath()+"setting.properties";
			in = new FileInputStream(path);
			Properties prop = new Properties();
			prop.load(new InputStreamReader(in, "UTF-8"));
			//转换文档允许的最大数量；默认值20M
			WordToPfdMaxSize=Integer.parseInt(prop.getProperty("WordToPfdMaxSize", "20"));
			cebaRemoteTestUrl = prop.getProperty("cebaRemoteTestUrl");
			cebaWebServiceUrl = prop.getProperty("cebaWebServiceUrl");
			cncaRemoteUrl = prop.getProperty("cncaRemoteUrl");
			cncaTestRemoteUrl= prop.getProperty("cncaTestRemoteUrl");
			cncaRemoteIp = prop.getProperty("cncaRemoteIp");
			String limitI =  prop.getProperty("limitIp", "true");
			HAND_WRITE_QR_URL = prop.getProperty("HAND_WRITE_QR_URL");
			CommonConfig.needLimitSizeFlag = "true".equals(prop.getProperty("needLimitSizeFlag", "true"))?true:false;
//			CommonConfig.WATERMARK_OVERCONTENT_FLAG = prop.getProperty("watermarkOverContent");
      limitIp = !"true".equals(limitI);

			cebaRemoteTestUrl = StringUtil.removeBlank(cebaRemoteTestUrl);
			cebaWebServiceUrl = StringUtil.removeBlank(cebaWebServiceUrl);
			cncaRemoteUrl = StringUtil.removeBlank(cncaRemoteUrl);
			cncaTestRemoteUrl = StringUtil.removeBlank(cncaTestRemoteUrl);
			cncaRemoteIp = StringUtil.removeBlank(cncaRemoteIp);
//			thirdUploadFileSystemUrl= StringUtil.removeBlank(thirdUploadFileSystemUrl);

			cncaRemoteUrl = StringUtil.addLastSlash(cncaRemoteUrl);
			cncaTestRemoteUrl = StringUtil.addLastSlash(cncaTestRemoteUrl);
			cebaWebServiceUrl = StringUtil.addLastSlash(cebaWebServiceUrl);

//			thirdUploadFileSystemUrl = StringUtil.deleteLastSlash(thirdUploadFileSystemUrl);
			CommonConfig.QF_SPLIT_WEIHT = StringUtil.isEmptyString(prop.getProperty("QF_SPLIT_WEIHT"))?QF_SPLIT_WEIHT:prop.getProperty("QF_SPLIT_WEIHT");
			CommonConfig.NEED_LTV = "true".equalsIgnoreCase(prop.getProperty("NEED_LTV", "false"))?true:false;
			CommonConfig.NEED_CRL = "true".equalsIgnoreCase(prop.getProperty("NEED_CRL", "true"))?true:false;
			CommonConfig.NEED_OCSP = "true".equalsIgnoreCase(prop.getProperty("NEED_OCSP", "false"))?true:false;
			CommonConfig.CERTIFICATE_LEVEL = StringUtil.isEmptyString(prop.getProperty("CERTIFICATE_LEVEL"))?CERTIFICATE_LEVEL:prop.getProperty("CERTIFICATE_LEVEL");
			ServerSignConfig.configServerSignConfig(prop);
			LdapConfig.config(prop);

			//初始化自定义日期章配置
			CUSTOM_DATE_FORMAT = prop.getProperty("custom_date_format", DateUtil.YYYY_MM_DD);
			CUSTOM_DATE_FONT = prop.getProperty("custom_date_font", StampFontFactory.FontFimilyEnum.CLASSICAL_SU_TONG.getCode());


			SIGN_CHANNEL_TYPE = prop.getProperty("SIGN_CHANNEL_TYPE", "2");
			/**
			 * 自动重传二维码上传失败的任务间隔
			 * 默认值：每5分钟重试一次
			 * 如要修改，遵循cron表达式格式
			 */
			QR_FILE_UPLOAD_TIME = prop.getProperty("QR_FILE_UPLOAD_TIME", "0 0/5 * * * ?");

			CebaConfig.CNCA_URL = prop.getProperty("CNCA_URL", "");
			CebaConfig.CNCA_UID = prop.getProperty("CNCA_UID", "");
			CebaConfig.CNCA_USERNAME = prop.getProperty("CNCA_USERNAME", "");
			CebaConfig.CNCA_PASSWORD = prop.getProperty("CNCA_PASSWORD", "");
			CebaConfig.CNCA_ORG_NAME = prop.getProperty("CNCA_ORG_NAME", "");
			CebaConfig.CNCA_ORG_CODE = prop.getProperty("CNCA_ORG_CODE", "");

			CebaConfig.SIGNATURE_STAMP_FLAG = "true".equalsIgnoreCase(prop.getProperty("SIGNATURE_STAMP_FLAG", "true"));
			CebaConfig.OTHER_STAMP_FLAG = "true".equalsIgnoreCase(prop.getProperty("OTHER_STAMP_FLAG", "true"));
			CebaConfig.WATERMARK_STAMP_FLAG = "true".equalsIgnoreCase(prop.getProperty("WATERMARK_STAMP_FLAG", "true"));
			CebaConfig.IS_QIFENG_IN_ONE_PAGE_PDF = "true".equalsIgnoreCase(prop.getProperty("IS_QIFENG_IN_ONE_PAGE_PDF", "true"));

			CebaConfig.MAX_SIGNING_NUMBER_IN_API = Integer.parseInt(prop.getProperty("MAX_SIGNING_NUMBER_IN_API", "20"));

			CebaConfig.OFD_SERVICE_URL = prop.getProperty("OFD_SERVICE_URL", "http://localhost:8070");
			//允许PDF内容复制
			CebaConfig.AllowCopy = StringUtils.equals(prop.getProperty(ParamConstants.ALLOW_PDF_CONTENT_COPY,"false"), "true");
			tuvParamMap.put(ParamConstants.ALLOW_PDF_CONTENT_COPY, CebaConfig.AllowCopy);
			//允许打印
			CebaConfig.AllowPriting = StringUtils.equals(prop.getProperty(ParamConstants.ALLOW_PDF_PRINT, "true"), "true");
			tuvParamMap.put(ParamConstants.ALLOW_PDF_PRINT, CebaConfig.AllowPriting);
			//用户签名功能界面上是否展示可复制
			CebaConfig.SHOW_USER_ALLOW_COPY_VIEW = StringUtils.equals(prop.getProperty(ParamConstants.SHOW_USER_ALLOW_COPY_VIEW,"false"), "true") ;
			tuvParamMap.put(ParamConstants.SHOW_USER_ALLOW_COPY_VIEW, CebaConfig.SHOW_USER_ALLOW_COPY_VIEW);
			//用户签名功能界面上是否展示可添加二维码
			CebaConfig.SHOW_USER_ALLOW_ADD_QR_VIEW = StringUtils.equals(prop.getProperty(ParamConstants.SHOW_USER_ALLOW_ADD_QR_VIEW,"false"), "true");
			tuvParamMap.put(ParamConstants.SHOW_USER_ALLOW_ADD_QR_VIEW, CebaConfig.SHOW_USER_ALLOW_ADD_QR_VIEW);
			//用户签名功能界面上可添加二维码默认不添加
			CebaConfig.DEFAULT_USER_ALLOW_ADD_QR = StringUtils.equals(prop.getProperty(ParamConstants.DEFAULT_USER_ALLOW_ADD_QR, "false"), "true");
			tuvParamMap.put(ParamConstants.DEFAULT_USER_ALLOW_ADD_QR, CebaConfig.DEFAULT_USER_ALLOW_ADD_QR);
			//控制签名时关键字没匹配上是否报错 true-不报错 false-报错
			CebaConfig.NO_ERROR_NOT_NORMAL_MATCH_KEY = StringUtils.equals(prop.getProperty(ParamConstants.NO_ERROR_NOT_NORMAL_MATCH_KEY, "false"), "true");
			tuvParamMap.put(ParamConstants.NO_ERROR_NOT_NORMAL_MATCH_KEY, CebaConfig.NO_ERROR_NOT_NORMAL_MATCH_KEY);
			//控制API签名时关键字没匹配上是否报错 true-不报错 false-报错
			CebaConfig.NO_ERROR_NOT_NORMAL_MATCH_API_KEY = StringUtils.equals(prop.getProperty(ParamConstants.NO_ERROR_NOT_NORMAL_MATCH_KEY_API, "true"), "true");
			tuvParamMap.put(ParamConstants.NO_ERROR_NOT_NORMAL_MATCH_KEY_API, CebaConfig.NO_ERROR_NOT_NORMAL_MATCH_API_KEY);
			//控制API签名时添加二维码默认不添加
			CebaConfig.ADD_QR_FOR_API_KEY = StringUtils.equals(prop.getProperty(ParamConstants.ADD_QR_FOR_API_KEY,"false"), "true");
			tuvParamMap.put(ParamConstants.ADD_QR_FOR_API_KEY, CebaConfig.ADD_QR_FOR_API_KEY);
		} catch (Exception e) {
			LoggerHelper.error(logger, e,"加载ep_setting出错");
		} finally {
			if (null != in) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
					LoggerHelper.error(logger, e,"关闭ep_setting.properties文件出错");
				}
			}
		}
	}


	/**
	 * 获取一个key的值
	 * @param key
	 * @return
	 */
	public static String get(String key) {
		return MysqlUtils.getColumnValue("config","KEY","VALUE",key);
	}

	/**
	 * 获取一个key的值
	 * @param key
	 * @param defaultValue 如果获取的值为空或null，就返回这个默认值
	 * @return
	 */
	public static String get(String key,String defaultValue) {
		return MysqlUtils.getColumnValue("config","KEY","VALUE",key,defaultValue);
	}

	/**
	 * 重新获取签名相关信息
	 * @return
	 */
	public static void updateSignInfo(){
		try {
			SIGN_VALIDITY = get("SIGN_VALIDITY");
			SIGN_COMPANY = getDecode(get("SIGN_COMPANY"));
			SING_COMPANY_ACTIVATE_FLAG = get("SING_COMPANY_ACTIVATE_FLAG");

			ALLOW_LOGIN_DATE= getDecode(get("ALLOW_LOGIN_DATE"));
			ALLOW_SIGN_NUM= getDecode(get("ALLOW_SIGN_NUM"));

			ALL_SIGNCOUNT_REPORT = getDecode(get("ALL_SIGNCOUNT_REPORT"));
			YEAR_SIGNCOUNT_REPORT = getDecode(get("YEAR_SIGNCOUNT_REPORT"));
			ALL_SIGNCOUNT_ATTACH = getDecode(get("ALL_SIGNCOUNT_ATTACH"));
			YEAR_SIGNCOUNT_ATTACH = getDecode(get("YEAR_SIGNCOUNT_ATTACH"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 获取一个key的值
	 * @param key
	 * @param value 如果获取的值为空或null，就返回这个默认值
	 * @return
	 */
	public static Boolean set(String key,String value) {
		if("SIGN_COMPANY".equals(key)){
			value = IDSStringUtils.replaceN(value);
		}
		return MysqlUtils.setColumnValue("config","KEY","VALUE",key,value);
	}

  public static Boolean getMatchApiKeyOfTuvParam() {
		return (boolean) CebaConfig.tuvParamMap.getOrDefault(ParamConstants.NO_ERROR_NOT_NORMAL_MATCH_KEY_API, true);
	}
}
